import echarts from 'echarts'
const fontSize = 38

export default {
  fontSize,
  xAxis(val) {
    return {
      show: true,
      axisTick: {
        show: true
      },
      data: val.xAxisData,
      axisLine: {
        show: true
      },
      axisLabel: {
        show: true,
        interval: 0,
        fontSize,
      }
    }
  },
  yAxis(val) {
    return {
      show: true,
      axisTick: {
        show: true,
      },
      axisLine: {
        show: true
      },
      axisLabel: {
        show: true,
        fontSize,
      },
      splitLine: {
        show: true,
        interval: 0,
      },
      min: val.min,
      max: val.max,
      interval: val.interval,
      formatter: val.formatter,
    }
  },
  color(linear = false) {
    if (linear) {
      return [
        new echarts.graphic.LinearGradient(
          0, 0, 0, 1,
          [{ offset: 0, color: '#689FF9' },
            { offset: 1, color: '#1869EC' }]
        ),
        new echarts.graphic.LinearGradient(
          0, 0, 0, 1,
          [{ offset: 0, color: '#F99A5F' },
            { offset: 1, color: '#FF7723' }]
        )
      ]
    }
  },
  bar(val) {
    return {
      barWidth: 80,
    }
  },
  line(val) {
    return {
      smooth: false,
      symbol: 'circle',
      symbolSize: 10,
    }
  },
  ring(val) {
    return {
      radius: ['50%', '75%'],
      label: { show: false, }
    }
  },
  pie(val) {
    return {
      radius: '75%',
      label: false,
    }
  },
}
